package com.renting.modules.taskJob.entity.Job.impl;

import com.renting.modules.message.entity.SimpleMessage;
import com.renting.modules.message.service.MessageService;
import com.renting.modules.taskJob.entity.Job.BaseJob;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;


public class NewJob implements BaseJob {


    @Autowired
    MessageService messageService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        SimpleMessage simpleMessage = new SimpleMessage();
        simpleMessage.setContent("哈哈哈");
        try {
            messageService.sendSimpleMessageToAll(simpleMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
